package com.sojson.project.service.impl;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.sojson.project.dao.MeanContentDao;
import com.sojson.project.dao.MeanDao;
import com.sojson.project.entity.po.Mean;
import com.sojson.project.service.MeanService;

/**
 * 协议表Service实现类
 * 
 * @author liu
 * @date 2021-03-19
 */
@Service
public class MeanServiceImpl implements MeanService {

    @Resource
    private MeanDao meanDaoImpl;
    @Resource
    private MeanContentDao meanContentDaoImpl;

    /**
     * 单条插入
     * 
     * @param mean
     * @return
     * @throws SQLException
     */
    @Override
    public int insert(Mean mean) {
        int insert = meanDaoImpl.insert(mean);
        return insert;
    }

    /**
     * 批量插入
     * 
     * @param mean
     * @return
     * @throws SQLException
     */
    @Override
    public int insertList(Mean mean) {
        int insertList = meanDaoImpl.insertList(mean.getMeans());
        return insertList;
    }

    /**
     * 通过对象批量删除(物理删除)
     * 
     * @param mean
     * @return
     * @throws SQLException
     */
    @Override
    public int deleteByDto(Mean mean) {
        int deleteByDto = meanDaoImpl.deleteByDto(mean);
        return deleteByDto;
    }

    /**
     * 统计全部数量
     * 
     * @return
     * @throws SQLException
     */
    @Override
    public int countAll() {
        int countAll = meanDaoImpl.countAll();
        return countAll;
    }

    /**
     * 查询所有
     * 
     * @return
     * @throws SQLException
     */
    @Override
    public List<Mean> findAll() {
        List<Mean> findAll = meanDaoImpl.listAll();
        return findAll;
    }

    /**
     * 根据对象统计数量
     * 
     * @param mean
     * @return
     * @throws SQLException
     */
    @Override
    public int countByDto(Mean mean) {
        int countByDto = meanDaoImpl.countByDto(mean);
        return countByDto;
    }

    /**
     * 根据对象查询
     * 
     * @param mean
     * @return
     * @throws SQLException
     */
    @Override
    public List<Mean> findByDto(Mean mean) {
        List<Mean> findByDto = meanDaoImpl.listByDto(mean);
        return findByDto;
    }

    /**
     * 通过id删除(物理删除)
     * 
     * @param id
     * @return
     * @throws SQLException
     */
    @Override
    public int deleteById(Integer id) {
        int deleteById = meanDaoImpl.deleteById(id);
        return deleteById;
    }

    /**
     * 通过id列表删除(物理删除)
     * 
     * @param ids
     * @return
     * @throws SQLException
     */
    @Override
    public int deleteByIdList(ArrayList<Integer> ids) {
        int deleteByIdList = meanDaoImpl.deleteByIdList(ids);
        return deleteByIdList;
    }

    /**
     * 通过id更新(全部更新)
     * 
     * @param mean
     * @return
     * @throws SQLException
     */
    @Override
    public int updateById(Mean mean) {
        int updateById = meanDaoImpl.updateById(mean);
        return updateById;
    }

    /**
     * 通过id列表更新(全部更新)(更新内容相同)
     * 
     * @param mean
     * @return
     * @throws SQLException
     */
    @Override
    public int updateStaticByIdList(Mean mean) {
        int updateStaticByIdList = meanDaoImpl.updateStaticByIdList(mean);
        return updateStaticByIdList;
    }

    /**
     * 通过id列表更新(全部更新)(更新内容不相同)
     * 
     * @param mean
     * @return
     * @throws SQLException
     */
    @Override
    public int updateChangeByIdList(Mean mean) {
        int updateChangeByIdList = meanDaoImpl.updateChangeByIdList(mean.getMeans());
        return updateChangeByIdList;
    }

    /**
     * 通过id更新(局部更新)
     * 
     * @param mean
     * @return
     * @throws SQLException
     */
    @Override
    public int updatePartialById(Mean mean) {
        int updatePartialById = meanDaoImpl.updatePartialById(mean);
        return updatePartialById;
    }

    /**
     * 通过id列表更新(局部更新)(更新内容相同)
     * 
     * @param mean
     * @return
     * @throws SQLException
     */
    @Override
    public int updateStaticPartialByIdList(Mean mean) {
        int updateStaticPartialByIdList = meanDaoImpl.updateStaticPartialByIdList(mean);
        return updateStaticPartialByIdList;
    }

    /**
     * 通过id列表更新(局部更新)(更新内容不相同)
     * 
     * @param mean
     * @return
     * @throws SQLException
     */
    @Override
    public int updateChangePartialByIdList(Mean mean) {
        int updateChangePartialByIdList = meanDaoImpl.updateChangePartialByIdList(mean.getMeans());
        return updateChangePartialByIdList;
    }

    /**
     * 通过id查询
     * 
     * @param id
     * @return
     * @throws SQLException
     */
    @Override
    public Mean findById(Integer id) {
        Mean findById = meanDaoImpl.findById(id);
        return findById;
    }

    /**
     * 通过id列表查询
     * 
     * @param ids
     * @return
     * @throws SQLException
     */
    @Override
    public ArrayList<Mean> findByIdList(ArrayList<Integer> ids) {
        ArrayList<Mean> findByIdList = meanDaoImpl.findByIdList(ids);
        return findByIdList;
    }

    /**
     * 通过对象查询id列表
     * 
     * @param mean
     * @return
     * @throws SQLException
     */
    @Override
    public ArrayList<Integer> findIdByDto(Mean mean) {
        ArrayList<Integer> findIdByDto = meanDaoImpl.findIdByDto(mean);
        return findIdByDto;
    }

    /**
     * 清空数据(物理清空)
     * 
     * @throws SQLException
     */
    @Override
    public void clear() {
        meanDaoImpl.clear();
    }

    /**
     * 通过id修改状态
     * 
     * @param mean
     * @return
     * @throws SQLException 
     */
    @Override
    public int updateStatusById(Mean mean) {
        return meanDaoImpl.updatePartialById(mean);
    }

    /**
     * 通过id删除(物理删除)
     * 
     * @param ids
     * @return
     */
    @Override
    public int deleteByIds(Integer ids) {
        return meanDaoImpl.deleteByIds(ids);
    }

    /**
     * 通过协议编号删除(物理删除)
     * 
     * @param meanNos
     * @return
     */
    @Override
    public int deleteByMeanNos(String[] meanNos) {
        meanContentDaoImpl.deleteByMeanNos(meanNos);
        return meanDaoImpl.deleteByMeanNos(meanNos);
    }

    /**
     * 查询协议
     * 
     * @param mean
     * @return
     */
    @Override
    public Mean getInfo(Mean mean) {
        return meanDaoImpl.getInfo(mean);
    }

}